// let _router = {}

// _router[10] = (socket, arr) => {
//     // console.log(socket, arr)
//     socket.send([170, 0, 0])
// }

// module.exports = _router


class Router {
    constructor(){
        this.devices = {}
    }
    //心跳
    command1(socket, arr, devices){
        this.devices[arr[0]] = this.newDevicesStatus(arr)
        socket.send(this.responseMsg(arr))
    }

    //异常上报
    command2(socket, arr, devices){
        this.devices[arr[0]] = this.newDevicesStatus(arr)
        socket.send(this.responseMsg(arr))
    }

    //状态上报
    command3(socket, arr, devices){
        devices = this.newDevicesStatus(arr)
        socket.send(this.responseMsg(arr))
    }

    command5(socket, arr){
        
    }



    responseMsg(arr){
        return [arr[0], arr[1], arr[2], 0]
    }

    newDevicesStatus(arr){
        return {
            freezerControlMode: arr[4],
            freezerWorkStatus: arr[5],
            freezerDeviceStatus: arr[6],
            thermotank1ControlMode: arr[7],
            thermotank1WorkStatus: arr[8],
            thermotank1DeviceStatus: arr[9],
            thermotank2ControlMode: arr[10],
            thermotank2WorkStatus: arr[11],
            thermotank2DeviceStatus: arr[12],
            outport1Status: arr[13],
            outport2Status: arr[14],
            inport1Status: arr[15],
            inport1MealId: arr[16],
            inport2Status: arr[17],
            inport2MealId: arr[18],
            warning1: arr[19],
            warning2: arr[20],
            status: 1
        }
    }
}

module.exports = Router